
'''
预约设置服务类,将一个服务封装成一个类
服务名UserService
方法1:UserService          方法名:find_by_username
'''
import json

from api.base_service import BaseService


class UserService(BaseService):

    def __init__(self):
        super().__init__()
        self.service_name = "UserService"
    # 添加预约设置 Definition： Definition： User findByUsername(String username)
    def find_by_username(self,name):
        resp = self.client.invoke(self.service_name, "findByUsername",name)
        # 成功:字典格式的字符串信息
        # 失败:没有class 报"No"
        # 失败:{"orderDate":"2021-06-13","number":"60","class":"com.itheima.pojo.OrderSetting"} "Failed"
        if resp == "No" or resp == "Failed":
            return None
        else:
            return json.loads(resp)
if __name__ == '__main__':
    resp = UserService().find_by_username("admin")
    print(type(resp),resp)